<?php

namespace app\core;

use think\Controller as tpController;
use think\Request;

class Controller extends tpController {

    protected $requestParam;

    public function __construct() {
        parent::__construct();
        $this->requestParam = Request::instance()->param();
    }

    public function response($errno, $error, $result = array()) {
        $response = [
            'errorcode' => $errno,
            'message'   => $error
        ];

        return array_merge($response, $result);
    }

    public function responseSuccess($result = array()) {
        $success = [
            'errorcode' => 0,
            'message'   => 'success'
        ];

        return array_merge($success, $result);
    }

    public function responseFail($errno, $error, $result = array()) {
        $fail = [
            'errorcode' => $errno,
            'message'   => $error
        ];
        config('elk_status', $errno);

        return array_merge($fail, $result);
    }
}
